package zdream.pmfield.stage.message;

import java.util.Objects;

import zdream.pmfield.stage.object.FoeActor;

/**
 * @author Zdream
 * @date 2023-11-17
 * @since 0.0.1
 */
public class TimelineOrderChangeMessage extends StageMessage {
	public final FoeActor foe;
	public float speedRemainsFrom, speedRemainsTo;

	public TimelineOrderChangeMessage(FoeActor foe) {
		this.type = StageMessageType.REPORT;
		this.foe = Objects.requireNonNull(foe);
	}

	public TimelineOrderChangeMessage withSpeedRemainChanged(float from, float to) {
		speedRemainsFrom = from;
		speedRemainsTo = to;
		return this;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder(64);
		builder.append("[TO]").append(' ');
		foe.appendStringWithoutHp(builder);
		builder.append(' ').append("的行动");
		if (speedRemainsFrom < speedRemainsTo) {
			builder.append("被推迟");
		} else if (speedRemainsFrom > speedRemainsTo) {
			builder.append("被提前");
		} else {
			builder.append("没有改变");
		}

		builder.append('，');
		builder.append("下次行动时间剩余:").append(' ').append(speedRemainsFrom).append(' ')
				.append("->").append(' ').append(speedRemainsTo);

		return builder.toString();
	}
}
